// Copyright 2007 Google Inc.
// All Rights Reserved.

package com.google.jessewilson.codesearch.commandlinesearch;

import com.google.jessewilson.codesearch.api.SearchProvider;
import com.google.jessewilson.codesearch.api.spi.SearchProviderBackend;
import com.google.jessewilson.codesearch.api.spi.SearchProviderConfigurationEditor;
import com.google.jessewilson.codesearch.api.spi.SearchProviderParametersEditor;
import com.google.jessewilson.codesearch.configuration.SearchProviderConfiguration;

/**
 * @author Ted Mao (tmao@google.com)
 */
public class ClsSearchProvider extends SearchProvider {

  @Override
  public String getName() {
    return "Command line search";
  }

  public Class<? extends SearchProviderConfigurationEditor> getConfigurationEditor() {
    return ClsConfigurationEditor.class;
  }

  public Class<? extends SearchProviderConfiguration> getConfiguration() {
    return ClsConfiguration.class;
  }

  @Override public Class<? extends SearchProviderBackend> getBackend() {
    return ClsSearchProviderBackend.class;
  }

  @Override public Class<? extends SearchProviderParametersEditor> getParametersEditor() {
    return ClsSearchProviderParametersEditor.class;
  }

  @Override public SearchProviderConfiguration createDefaultConfiguration() {
    return new ClsConfiguration.Builder()
        .executable("/usr/local/symlinks/gsearch")
        .arguments("-n")
        .parseLineRegex("([^\\:]+)\\:([^\\:]+)\\:(.*)")
        .filePathMatch(1)
        .lineNumberMatch(2)
        .lineValueMatch(3)
        .build();
  }
}
